﻿using System.Data;
using Guru.Data;
using Telerik.Web.UI;
using Guru.Web.Controls.Asp;
using System;

public partial class FE_ManageBooking : HSMPage
{
    protected const string LINK_BOOKING_DETAIL = "<a class='rgLinkIcon rgLinkEdit' onclick=\"OpenPopupModal(1, 'CheckInModal.aspx?{1}');\">{0}</a>";

    protected void uxBookingGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            DataRowView dv = item.DataItem as DataRowView;
            string secParams = BuildSecureQueryString(string.Format("InvoiceID={0}&FromBooking=1@SBookStatus={1}", dv["RoomBookID"], dv["Status"]));
            item["BookingNumber"].Text = string.Format(LINK_BOOKING_DETAIL, dv["BookingNumber"], secParams);
        }
    }
    protected void uxBookingGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        GuruParameterCollection parameters = new GuruParameterCollection();
        parameters.AddUserLoggedParams();
        parameters.Add("@BookingNumber", this.uxBookingNumber.Text.Trim(), DbType.AnsiString);
        if (uxFromDate.SelectedDate != null)
        {
            parameters.Add("@FromDate", uxFromDate.SelectedDate.Value.Date, DbType.Date);
        }
        if (uxToDate.SelectedDate != null)
        {
            parameters.Add("@ToDate", uxToDate.SelectedDate.Value.Date, DbType.Date);
        }
        DataTable dt = HSMCommon.HSMBusiness.GetDataTable("spa_HSM_Booking_GetAll", parameters);
        uxBookingGrid.DataSource = dt;
    }

    protected void uxSearch_Click(object sender, EventArgs e)
    {
        uxBookingGrid.Rebind();
    }
}
